﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using Hi_Baidu.Entry.CollectionObject;

namespace Hi_Baidu.ProcessModel
{
    public partial class GetContextMenuViewModel : Model
    {
        private delegate void PUBLIC_DELDGATE();
        private static void OnFriendTreeContextMenuClicked(Object sender, RoutedEventArgs e)
        {
            TreeViewItem SelectedItem = (Globle.win_Main.TV_FriendList.SelectedItem as TreeViewItem);
            MenuItem SelectedMenuItem = e.Source as MenuItem;
            if (SelectedItem != null && SelectedMenuItem!= null)
            {
                if (SelectedItem.Tag is Item)
                {
                    switch (SelectedMenuItem.Header.ToString())
                    {
                        case "重命名(_B)":
                            //重命名部分
                            FriendTreeViewModel.RenameItem(SelectedItem);
                            break;
                        case "添加分组":
                            //添加分组部分
                            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background,
                                                                                 new PUBLIC_DELDGATE(
                                                                                     FriendTreeViewModel.AddItem));
                            break;
                        case "删除分组":
                            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background,
                                                                                 new PUBLIC_DELDGATE(
                                                                                     FriendTreeViewModel.DeleteItem));
                            break;
                        case "添加好友":
                            Globle.win_Main.ShowPostAddFriend();
                            break;
                    }
                }
                if (SelectedItem.Tag is Friend)
                {
                    switch (SelectedMenuItem.Header.ToString())
                    {
                        case "删除好友":
                            MainBoardViewModel.DeleteFriend();
                            break;
                    }
                }
            }
        }
    }
}
